package com.itheima.controller;


import com.itheima.common.ResultData;
import com.itheima.domain.CmsSubject;
import com.itheima.manager.CmsSubjectManager;
import com.itheima.service.CmsSubjectService;
import com.itheima.util.PageBean;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 专题表 前端控制器
 * </p>
 *
 * @author XiaoRan
 * @since 2022-08-02
 */
@Slf4j
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/subject")
public class CmsSubjectController {

    @Autowired
    CmsSubjectManager subjectManager;

    //获取全部商品专题
    @GetMapping("/listAll")
    public ResultData listAll() {
        log.info("获取全部商品专题");
        List<CmsSubject> list = subjectManager.list();
        return ResultData.ok(list, "");
    }

    //根据专题名称分页获取商品专题
    @GetMapping("/list")
    public ResultData list(String keyword, Integer pageNum, Integer pageSize) {
        log.info("根据专题名称分页获取商品专题");
        PageBean pageInfo = subjectManager.pageInfo(keyword, pageNum, pageSize);
        return ResultData.ok(pageInfo, "");
    }

}
